package com.zzsy.carosshopprojects.util;

import android.content.Context;
import android.os.CountDownTimer;

/**
 * Created by Administrator on 2019/12/26 0026.
 */

public class CusCountDownUtils extends CountDownTimer {
    private static final int TIME = 1000;
    private Context mContext;

    public CusCountDownUtils(Context context, long millisInFuture) {
        super(millisInFuture * 1000, TIME);
        this.mContext = context;
    }

    /**
     * 按照设置时间 没过一秒 走一遍该方法
     * */
    @Override
    public void onTick(long millisUntilFinished) {
        onclickTimeListener.onTicks(millisUntilFinished);
    }

    /**
     * 倒计时结束的时候 执行该方法
     * */
    @Override
    public void onFinish() {
        onclickTimeListener.onFinish();
    }

    private OnclickTimeListener onclickTimeListener;

    public interface OnclickTimeListener{
        void onTicks(long millisUntilFinished);
        void onFinish();
    }

    public void setOnclickTimeListener(OnclickTimeListener onclickTimeListener) {
        this.onclickTimeListener = onclickTimeListener;
    }
}
